<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('充值详情列表')" />
</head>
<body class="gray-bg">
     <div class="container-div">
        <div class="row">
            <div class="col-sm-12 search-collapse">
                <form id="formId">
                    <div class="select-list">
                        <ul>
                            <li>
                                <label style="width: 100px;">系统流水：</label>
                                <input type="text" name="serial"/>
                            </li>
                            <li>
                                <label style="width: 100px;">服务商编号：</label>
                                <input type="text" name="agentNum"/>
                            </li>
                            <li>
                                <label style="width: 100px;">交易类型：</label>
                                <select name="type" th:with="type=${@dict.getType('finance_transaction_type')}">
                                    <option value="">所有</option>
                                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                                </select>
                            </li>
                            <li class="select-time">
                                <label style="width: 100px;">交易时间：</label>
                                <input type="text" class="time-input" id="startTime" placeholder="开始时间" name="params[beginTradingDate]"/>
                                <span>-</span>
                                <input type="text" class="time-input" id="endTime" placeholder="结束时间" name="params[endTradingDate]"/>
                            </li>
                            <li>
                                <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                                <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                            </li>
                        </ul>
                    </div>
                </form>
            </div>

            <div class="btn-group-sm" id="toolbar" role="group">
                <a class="btn btn-success single" onclick="viewVoucher()" shiro:hasPermission="agentInfo:accountDetails:viewVoucher">
                    <i class="fa fa-plus"></i> 查看凭证
                </a>
            </div>
            <div class="col-sm-12 select-table table-striped">
                <table id="bootstrap-table"></table>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var typeDatas = [[${@dict.getType('finance_transaction_type')}]];
        var bursementDatas = [[${@dict.getType('sys_is_not')}]];
        var prefix = ctx + "agentInfo/accountDetails";

        $(function() {
            var options = {
                url: prefix + "/list",
                createUrl: prefix + "/add",
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/remove",
                exportUrl: prefix + "/export",
                clickToSelect: true,
                modalName: "充值详情",
                columns: [{
                    radio: true
                },
                {
                    field: 'id',
                    title: '主键',
                    visible: false
                },
                {
                    field: 'agentNum',
                    title: '服务商编号'
                },
                {
                    field: 'agentName',
                    title: '服务商名称'
                },
                {
                    field: 'type',
                    title: '交易类型',
                    formatter: function(value, row, index) {
                       return $.table.selectDictLabel(typeDatas, value);
                    }
                },
                {
                    field: 'money',
                    title: '交易金额'
                },
                {
                    field: 'tradingDate',
                    title: '交易时间'
                },
                {
                    field: 'underlayName',
                    title: '垫资方名称'
                },
                {
                    field: 'underlayNum',
                    title: '垫资方编号'
                },
                {
                    field: 'serial',
                    title: '系统流水'
                },
                {
                    field: 'bursement',
                    title: '是否还款',
                    formatter: function(value, row, index) {
                       return $.table.selectDictLabel(bursementDatas, value);
                    }
                },
                {
                    field: 'hkCreatedate',
                    title: '还款时间'
                },
                {
                    field: 'sjhk',
                    title: '实际还款'
                },
                {
                    field: 'sjcz',
                    title: '实际充值'
                },
                {
                    field: 'man',
                    title: '扣款类型',
                    formatter: function(value, row, index) {
                        if (value == "admin"){
                            return '服务费扣款';
                        } else if (value == "tj"){
                            return '高签分润扣款';
                        } else if (value == "yf"){
                            return '月返扣款';
                        } else if (value == "bt"){
                            return '达标返现补贴扣款';
                        }
                    }

                }]
            };
            $.table.init(options);
        });

        function viewVoucher() {
            //如果是移动端，就使用自适应大小弹窗
            var width=1000;
            var height=$(window).height() - 50;
            if ($.common.isMobile()) {
                width = 'auto';
                height = 'auto';
            }

            var agentNum = $.table.selectColumns("agentNum");
            var serial = $.table.selectColumns("serial");
            if (agentNum.length == 0) {
                $.modal.alertWarning("请选择一条记录");
                return;
            }
            var url=prefix + '/viewVoucher?agent_num='+agentNum+"&serial="+serial;
            //$.modal.open("商品详情", url,width, height);
            var btn = ['关闭'];
            var options = {
                title: '查看凭证图片',
                width: width,
                height: height,
                url: url,
                btn: btn,
                yes:function(index){
                    layer.close(index);
                }
            };
            $.modal.openOptions(options);
        }
    </script>
</body>
</html>